package com.example.moviegroup.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.RelativeLayout;

import com.example.moviegroup.R;
import com.example.moviegroup.activity.ChouJiangActivity;
import com.example.moviegroup.activity.LoginActivity;
import com.example.moviegroup.activity.MainActivity;
import com.example.moviegroup.activity.MoreActivity;
import com.example.moviegroup.activity.MoveMessageActivity;
import com.example.moviegroup.activity.Y1YActivity;
import com.example.moviegroup.adapter.ExpandAdapter;


public class MineFragment extends Fragment implements View.OnClickListener, ExpandableListView.OnChildClickListener {

	ExpandableListView exp_list1;
	ExpandAdapter adapter;
	View view;
	Button btn_sao,btn_denglu,btn_my;
	RelativeLayout rel_item1,rel_item2,rel_item3,rel_item4,rel_item5;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		 view = inflater.inflate(R.layout.fragment_mine,null);
		initView();
		setListener();
		initData();
		return view;
	}

	public void initView() {
		exp_list1 = (ExpandableListView) view.findViewById(R.id.exp_list);
		btn_sao = (Button) view.findViewById(R.id.btn_sao);
		btn_denglu = (Button) view.findViewById(R.id.btn_denglu);
		btn_my = (Button) view.findViewById(R.id.btn_my);
		rel_item1 = (RelativeLayout) view.findViewById(R.id.relative_item1);
		rel_item2 = (RelativeLayout) view.findViewById(R.id.relative_item2);
		rel_item3 = (RelativeLayout) view.findViewById(R.id.relative_item3);
		rel_item4 = (RelativeLayout) view.findViewById(R.id.relative_item4);
		rel_item5 = (RelativeLayout) view.findViewById(R.id.relative_item5);

	}

	public void setListener() {
		btn_sao.setOnClickListener(this);
		btn_denglu.setOnClickListener(this);
		btn_my.setOnClickListener(this);
		rel_item1.setOnClickListener(this);
		rel_item2.setOnClickListener(this);
		rel_item3.setOnClickListener(this);
		rel_item4.setOnClickListener(this);
		rel_item5.setOnClickListener(this);
		exp_list1.setOnChildClickListener(this);
	}

	public void initData() {
		adapter = new ExpandAdapter(getActivity());
		exp_list1.setAdapter(adapter);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()){
			case R.id.btn_sao:
				Intent intnet7 = new Intent(getActivity(), ChouJiangActivity.class);
				startActivity(intnet7);
				break;
			case R.id.btn_denglu:
				Intent intnet6 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intnet6);
				break;
			case R.id.btn_my:
				Intent intnet5 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intnet5);
				break;
			case R.id.relative_item1:
				Intent intnet4 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intnet4);
				break;
			case R.id.relative_item2:
				Intent intnet3 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intnet3);
				break;
			case R.id.relative_item3:
				Intent intnet2 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intnet2);
				break;
			case R.id.relative_item4:
				Intent intent1 = new Intent(getActivity(), LoginActivity.class);
				startActivity(intent1);
				break;
			case R.id.relative_item5:
				Intent intent  = new Intent(getActivity(), MoreActivity.class);
				startActivity(intent);
				break;
		}
	}

	@Override
	public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
			Intent intent = new Intent(getActivity(),LoginActivity.class);
			startActivity(intent);
		return true;
	}
}
